<?php 

namespace pmvc\util;


/**
 * Utilities for working with files
 * 
 */
class FileUtil {

	/**
	 * Returns the path name for {@link $file} relative
	 * to {@link $relativeTo}.
	 * @param string $file
	 * @param string $relativeFile
	 */
	public static function getRelativePath($file, $relativeTo) {
		if (file_exists($file)) {
			return $file;
			
		} else if (substr($file, 0, 1)!="/"
			&& file_exists(dirname($relativeTo)."/".$file)) {
			return dirname($relativeTo)."/".$file;
			
		} else if (substr($file, 0, 1)=="/"
			&& file_exists(dirname($relativeTo).$file)) {
			return dirname($relativeTo).$file;
			
		}

		return false;
	}
	
}

?>